/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/*
 * JDialog_ChonContact.java
 *
 * Created on Jun 21, 2009, 2:51:35 PM
 */

package doanlythuyet_javaoutlook.MyUserControl;

import java.util.ArrayList;

/**
 *
 * @author Administrator
 */
public class JDialog_ChonContact extends javax.swing.JDialog {

    private String cacEmailDuocChon;
    /** Creates new form JDialog_ChonContact */
    public JDialog_ChonContact(java.awt.Frame parent, boolean modal) {
        super(parent, modal);
        initComponents();
        jTable_HienThiContact1.refreshBang();
    }

    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jScrollPane1 = new javax.swing.JScrollPane();
        jTable_HienThiContact1 = new doanlythuyet_javaoutlook.MyUserControl.jTable_HienThiContact();
        jButton1 = new javax.swing.JButton();
        jButton2 = new javax.swing.JButton();

        setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
        setName("Form"); // NOI18N

        jScrollPane1.setName("jScrollPane1"); // NOI18N

        jTable_HienThiContact1.setModel(new javax.swing.table.DefaultTableModel(
            new Object [][] {
                {null, null, null, null},
                {null, null, null, null},
                {null, null, null, null},
                {null, null, null, null}
            },
            new String [] {
                "Title 1", "Title 2", "Title 3", "Title 4"
            }
        ));
        jTable_HienThiContact1.setName("jTable_HienThiContact1"); // NOI18N
        jScrollPane1.setViewportView(jTable_HienThiContact1);

        org.jdesktop.application.ResourceMap resourceMap = org.jdesktop.application.Application.getInstance(doanlythuyet_javaoutlook.DoAnLyThuyet_JavaOutLookApp.class).getContext().getResourceMap(JDialog_ChonContact.class);
        jButton1.setText(resourceMap.getString("jButton1.text")); // NOI18N
        jButton1.setName("jButton1"); // NOI18N
        jButton1.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton1ActionPerformed(evt);
            }
        });

        jButton2.setText(resourceMap.getString("jButton2.text")); // NOI18N
        jButton2.setName("jButton2"); // NOI18N
        jButton2.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton2ActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                        .addComponent(jButton1)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(jButton2))
                    .addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 733, Short.MAX_VALUE)))
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                .addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 231, Short.MAX_VALUE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jButton2)
                    .addComponent(jButton1))
                .addGap(40, 40, 40))
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents
    public ArrayList<String> LayCacEMailDuocChon (){
        ArrayList<String> Kq = new ArrayList<String>();
        for (int i = 0; i < jTable_HienThiContact1.getRowCount(); i++)
            if (jTable_HienThiContact1.getValueAt(i, 0) != null && (Boolean)jTable_HienThiContact1.getValueAt(i, 0)
            && jTable_HienThiContact1.getValueAt(i, 3) != null)
                Kq.add(jTable_HienThiContact1.getValueAt(i, 3).toString());
        return Kq;
    }
    private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton1ActionPerformed
        // TODO add your handling code here:
        ArrayList<String> cacEmail = LayCacEMailDuocChon();

        cacEmailDuocChon = "";
        for (int i = 0; i < cacEmail.size(); i++){
            cacEmailDuocChon += cacEmail.get(i) + ",";
        }
        setVisible(false);
    }//GEN-LAST:event_jButton1ActionPerformed

    private void jButton2ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton2ActionPerformed
        // TODO add your handling code here:
        setVisible(false);
    }//GEN-LAST:event_jButton2ActionPerformed

    /**
    * @param args the command line arguments
    */
    public static void main(String args[]) {
        java.awt.EventQueue.invokeLater(new Runnable() {
            public void run() {
                JDialog_ChonContact dialog = new JDialog_ChonContact(new javax.swing.JFrame(), true);
                dialog.addWindowListener(new java.awt.event.WindowAdapter() {
                    public void windowClosing(java.awt.event.WindowEvent e) {
                        System.exit(0);
                    }
                });
                dialog.setVisible(true);
            }
        });
    }

    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton jButton1;
    private javax.swing.JButton jButton2;
    private javax.swing.JScrollPane jScrollPane1;
    private doanlythuyet_javaoutlook.MyUserControl.jTable_HienThiContact jTable_HienThiContact1;
    // End of variables declaration//GEN-END:variables

    /**
     * @return the cacEmailDuocChon
     */
    public String getCacEmailDuocChon() {
        return cacEmailDuocChon;
    }

    /**
     * @param cacEmailDuocChon the cacEmailDuocChon to set
     */
    public void setCacEmailDuocChon(String cacEmailDuocChon) {
        this.cacEmailDuocChon = cacEmailDuocChon;
    }

}
